/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "prestamo_tipo", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PrestamoTipo.findAll", query = "SELECT p FROM PrestamoTipo p"),
    @NamedQuery(name = "PrestamoTipo.findByTpId", query = "SELECT p FROM PrestamoTipo p WHERE p.tpId = :tpId"),
    @NamedQuery(name = "PrestamoTipo.findByTpNombre", query = "SELECT p FROM PrestamoTipo p WHERE p.tpNombre = :tpNombre"),
    @NamedQuery(name = "PrestamoTipo.findByTpDescripcion", query = "SELECT p FROM PrestamoTipo p WHERE p.tpDescripcion = :tpDescripcion"),
    @NamedQuery(name = "PrestamoTipo.findByTpDiasMax", query = "SELECT p FROM PrestamoTipo p WHERE p.tpDiasMax = :tpDiasMax")})
public class PrestamoTipo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "tp_id")
    private Integer tpId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "tp_nombre", nullable = false, length = 20)
    private String tpNombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "tp_descripcion", nullable = false, length = 45)
    private String tpDescripcion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "tp_dias_max", nullable = false, length = 2)
    private String tpDiasMax;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "prestIdTp")
    private List<Prestamo> prestamoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "multapIdTp")
    private List<MultaPrestamo> multaPrestamoList;

    public PrestamoTipo() {
    }

    public PrestamoTipo(Integer tpId) {
        this.tpId = tpId;
    }

    public PrestamoTipo(Integer tpId, String tpNombre, String tpDescripcion, String tpDiasMax) {
        this.tpId = tpId;
        this.tpNombre = tpNombre;
        this.tpDescripcion = tpDescripcion;
        this.tpDiasMax = tpDiasMax;
    }

    public Integer getTpId() {
        return tpId;
    }

    public void setTpId(Integer tpId) {
        this.tpId = tpId;
    }

    public String getTpNombre() {
        return tpNombre;
    }

    public void setTpNombre(String tpNombre) {
        this.tpNombre = tpNombre;
    }

    public String getTpDescripcion() {
        return tpDescripcion;
    }

    public void setTpDescripcion(String tpDescripcion) {
        this.tpDescripcion = tpDescripcion;
    }

    public String getTpDiasMax() {
        return tpDiasMax;
    }

    public void setTpDiasMax(String tpDiasMax) {
        this.tpDiasMax = tpDiasMax;
    }

    @XmlTransient
    public List<Prestamo> getPrestamoList() {
        return prestamoList;
    }

    public void setPrestamoList(List<Prestamo> prestamoList) {
        this.prestamoList = prestamoList;
    }

    @XmlTransient
    public List<MultaPrestamo> getMultaPrestamoList() {
        return multaPrestamoList;
    }

    public void setMultaPrestamoList(List<MultaPrestamo> multaPrestamoList) {
        this.multaPrestamoList = multaPrestamoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tpId != null ? tpId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PrestamoTipo)) {
            return false;
        }
        PrestamoTipo other = (PrestamoTipo) object;
        if ((this.tpId == null && other.tpId != null) || (this.tpId != null && !this.tpId.equals(other.tpId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return tpNombre + ", " + tpDiasMax;
    }
    
}
